package com.example.intent;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        EditText URL = (EditText)findViewById(R.id.url);
        Button bn = findViewById(R.id.button);

        // 为bn按钮添加一个监听器
        bn.setOnClickListener(view -> {
            // 创建Intent
            Intent intent = new Intent();
            // 为Intent设置Action属性
            intent.setAction(Intent.ACTION_VIEW);
            // 设置Data属性
            intent.setData(Uri.parse(URL.getText().toString()));
            startActivity(intent);
        });
    }
}
